package com.example.aircraftwar.codes.strategy;

import static com.example.aircraftwar.codes.activity.GameActivity.game;

import android.content.Context;

import com.example.aircraftwar.codes.aircraft.AbstractAircraft;
import com.example.aircraftwar.codes.bullet.BaseBullet;
import com.example.aircraftwar.codes.bullet.EnemyBullet;

import java.util.LinkedList;
import java.util.List;


/**
 * @Author 200111518
 * 精英敌机一次直射一发子弹的射击方式
 *
 */

public class EnemyStraightShoot implements ShootStrategy{
    private int direction = 1;
    private int shootNum = 1;
    private int power = (int)(15 * game.getAttributeRate());

    @Override
    public List<BaseBullet> executeShootStrategy(Context context, AbstractAircraft abstractAircraft) {
        List<BaseBullet> res = new LinkedList<>();
        int x = abstractAircraft.getLocationX();
        int y = abstractAircraft.getLocationY() + direction * 100;
        int speedX = 0;
        int speedY = abstractAircraft.getSpeedY() + direction * 10;
        BaseBullet baseBullet;
        for (int i = 0; i < shootNum; i++) {
            // 子弹发射位置相对飞机位置向前偏移
            // 多个子弹横向分散
            baseBullet = new EnemyBullet(context, x + (i * 2 - shootNum + 1) * 10, y, speedX, speedY, power);
            res.add(baseBullet);
        }
        return res;
    }
}
